package com.taxicalculator.ui;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.ClipData.Item;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.taxicalculator.dto.Faq;

public class FaqAdapter extends ArrayAdapter<Faq>{

	 private final Context context;
     private final ArrayList<Faq> faqArrayList;

     public FaqAdapter(Context context, ArrayList<Faq> faqArrayList) {

         super(context, R.layout.faqview, faqArrayList);

         this.context = context;
         this.faqArrayList = faqArrayList;
}
     @Override
     public View getView(int position, View convertView, ViewGroup parent) {

         // Create inflater 
         LayoutInflater inflater = (LayoutInflater) context
             .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

         // Get view from inflater
         View faqView = inflater.inflate(R.layout.faqview, parent, false);

         // Get the two text view from the faqview
         TextView labelView = (TextView) faqView.findViewById(R.id.questionView);
         TextView valueView = (TextView) faqView.findViewById(R.id.answerView);

         // Set the text for textView 
         labelView.setText(faqArrayList.get(position).getQuestion());
         valueView.setText(faqArrayList.get(position).getAnswer());

         
         return faqView;
     }
   
}
